package com.takanafu.haru.code.builtins{
	import com.takanafu.haru.code.CodeBase;
	import com.takanafu.haru.code.CodeString;
	import com.takanafu.haru.core.GlobalManager;
	
	import mx.collections.ArrayCollection;
	import mx.controls.TextArea;
	
	public class Print extends AbstractBuitin{
		public function Print(){
			super(1);
		}
		
		override public function exec(params:ArrayCollection):CodeBase{
			var code:CodeBase = params.getItemAt(0) as CodeBase;
			var ta:TextArea = GlobalManager.stdOut;
			
			if(ta != null){
				var runcode:CodeBase = code.run();
				var strcode:CodeString = runcode as CodeString;
				
				if(strcode != null){
					ta.htmlText += strcode.getString() + "<br/>";
				}else{
					ta.htmlText += runcode.toString() + "<br/>";
				}
			}
			return null;
		}
		
	}
}